#version 450

layout(location=0) in vec3 a_Pos;
layout(location=1) in vec3 a_Normal;
layout(location=2) in vec3 a_Color;

layout (binding = 0) uniform UBO
{
    mat4 projMat;
    mat4 viewMat;
} ubo;

layout(binding=1) uniform UboInstance {
    mat4 modelMat;
} uboInstance;

layout(location=0) out vec3 v_Normal;
layout(location=1) out vec3 v_Color;
layout(location=2) out vec3 v_WorldPos;

void main() {
    gl_Position = ubo.projMat * ubo.viewMat * uboInstance.modelMat * vec4(a_Pos, 1.0);
    v_Normal = mat3(transpose(inverse(uboInstance.modelMat))) * a_Normal;
    v_Color = a_Color;
    v_WorldPos = vec3(uboInstance.modelMat * vec4(a_Pos, 1.0));
}